home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 25 / CU Amiga Magazine's Super CD-ROM 25 (1998)(EMAP Images)(GB)(Track 1 of 2)[!][issue 1998-08].iso / CUCD / Programming / EasyPLUGINs / source / bar.e next >
Encoding:
Text File  |  1998-05-20  |  2.3 KB  |  130 lines

  1.  
  2. /*
  3.  
  4.     $VER: bar_plugin 1.0 (25.5.98)
  5.  
  6.     Author:         Ali Graham
  7.                     <agraham@hal9000.net.au>
  8.  
  9.     Desc.:          Replacement for BAR with percentile width.
  10.  
  11. */
  12.  
  13.  
  14. OPT MODULE, OSVERSION=37
  15.  
  16. MODULE 'tools/easygui',
  17.        'intuition/intuition',
  18.        'utility', 'utility/tagitem'
  19.  
  20. EXPORT OBJECT bar_plugin OF plugin PRIVATE
  21.  
  22.     percent
  23.     vertical
  24.  
  25. ENDOBJECT
  26.  
  27. -> PROGRAMMER_ID | MODULE_ID
  28. ->      $01      |   $08
  29.  
  30.  
  31. EXPORT ENUM PLA_Bar_Percent=$81080001,     ->[IS.]
  32.             PLA_Bar_Vertical               ->[I..]
  33.  
  34. PROC bar(tags=NIL:PTR TO tagitem) OF bar_plugin
  35.  
  36.     IF utilitybase
  37.  
  38.         self.percent  := GetTagData(PLA_Bar_Percent, 100, tags)
  39.         IF self.percent<0 THEN self.percent:=0; IF self.percent>100 THEN self.percent:=100
  40.  
  41.         self.vertical:= GetTagData(PLA_Bar_Vertical, FALSE, tags)
  42.  
  43.     ELSE
  44.  
  45.         Raise("util")
  46.  
  47.     ENDIF
  48.  
  49. ENDPROC
  50.  
  51. PROC set(attr, value) OF bar_plugin
  52.  
  53.     SELECT attr
  54.  
  55.         CASE PLA_Bar_Percent
  56.  
  57.             IF self.percent<>value
  58.  
  59.                 self.percent:=value
  60.  
  61.                 self.draw()
  62.  
  63.             ENDIF
  64.  
  65.     ENDSELECT
  66.  
  67. ENDPROC
  68.  
  69. PROC draw(win=NIL:PTR TO window) OF bar_plugin
  70.  
  71.     DEF width, height, gap
  72.  
  73.     IF (win=NIL) THEN win:=self.gh.wnd
  74.  
  75.     SetStdRast(win.rport)
  76.  
  77.     Box(self.x, self.y, self.x + self.xs -1, self.y + self.ys -1, 0)
  78.  
  79.     IF self.percent>0
  80.  
  81.         IF self.vertical
  82.  
  83.             height:=((self.ys * self.percent) / 100)
  84.             gap:=(self.ys - height)/2
  85.  
  86.             Line((self.x + 1), (self.y + gap), (self.x + 1), ((self.y + self.ys - 1) - gap), 1)
  87.             Line((self.x + 2), (self.y + gap), (self.x + 2), ((self.y + self.ys - 1) - gap), 2)
  88.  
  89.         ELSE
  90.  
  91.             width:=((self.xs * self.percent) / 100)
  92.             gap:=(self.xs - width)/2
  93.  
  94.             Line((self.x + gap), (self.y + 1), ((self.x + self.xs - 1) - gap), (self.y + 1), 1)
  95.             Line((self.x + gap), (self.y + 2), ((self.x + self.xs - 1) - gap), (self.y + 2), 2)
  96.  
  97.         ENDIF
  98.  
  99.     ENDIF
  100.  
  101. ENDPROC
  102.  
  103. PROC min_size(ta,fh) OF bar_plugin
  104.  
  105.     DEF ret_x, ret_y
  106.  
  107.     IF self.vertical
  108.  
  109.         ret_x:=4
  110.         ret_y:=8
  111.  
  112.     ELSE
  113.  
  114.         ret_x:=8
  115.         ret_y:=4
  116.  
  117.     ENDIF
  118.  
  119. ENDPROC ret_x, ret_y
  120.  
  121. PROC will_resize() OF bar_plugin IS (IF self.vertical THEN RESIZEY ELSE RESIZEX)
  122.  
  123. PROC render(ta, x, y, xs, ys, win:PTR TO window) OF bar_plugin
  124.  
  125.     self.draw(win)
  126.  
  127. ENDPROC
  128.  
  129.  
  130.